#ifndef wm_client_h
#define wm_client_h
/*
 * Sylvain BERTRAND <digital.ragnarok@gmail.com>
 * code protected by GNU GPL v3
 */
enum wm_client_type {
	WM_CLIENT_TYPE_DESKTOP,
	WM_CLIENT_TYPE_DIALOG,
	WM_CLIENT_TYPE_NORMAL
};
struct wm_client {
	struct wm_window wm_win;
	Window window;
	gboolean managed;
	struct wm_frame *frame;
	gint ignore_unmaps;
	struct wm_group *group;
	gboolean transient;
	gboolean transient_for_group;
	GSList *parents;
	GSList *transients;
	guint desktop;
	gchar *startup_id;
	gchar *title;
	gchar *original_title;
	pid_t pid;
	gchar *name;
	gchar *class;
	enum wm_client_type type;
	struct wm_rect area;
	struct wm_point root_pos;
	struct wm_rect pre_max_area;
	struct wm_rect pre_fullscreen_area;
	gboolean pre_fullscreen_max_horz, pre_fullscreen_max_vert;
	struct strut_partial strut;
	struct wm_size logical_size;
	gint border_width;
	gfloat min_ratio;
	gfloat max_ratio;
	struct wm_size min_size;
	struct wm_size max_size;
	struct wm_size size_inc;
	struct wm_size base_size;
	Colormap colormap;
	gint gravity;
	glong wm_state;
	gboolean delete_window;
	guint positioned;
	guint sized;
	gboolean can_focus;
	gboolean focus_notify;
	gint kill_level;
	gboolean sync_request;
	guint32 sync_counter;
	gulong sync_counter_value;
	gboolean shaped;
	gboolean shaped_input;
	gboolean modal;
	gboolean max_vert;
	gboolean max_horz;
	gboolean skip_pager;
	gboolean skip_taskbar;
	gboolean fullscreen;
	gboolean above;
	gboolean below;
	gboolean demands_attention;
	gboolean urgent;
	enum wm_stacking_layer layer;
	gboolean visited;
};
typedef void (*wm_client_callback) (struct wm_client * client, gpointer data);
GList *client_list;
void client_startup(void);
void client_shutdown(void);
void client_add_destroy_notify(wm_client_callback func, gpointer data);
void client_remove_destroy_notify(wm_client_callback func);
void client_manage(Window win);
void client_unmanage_all(void);
void client_unmanage(struct wm_client *client);
gboolean client_should_show(struct wm_client *self);
gboolean client_normal(struct wm_client *self);
gboolean client_helper(struct wm_client *self);
gboolean client_mouse_focusable(struct wm_client *self);
gboolean client_enter_focusable(struct wm_client *self);
void client_gravity_resize_w(struct wm_client *self, gint *x, gint oldw, gint neww);
void client_gravity_resize_h(struct wm_client *self, gint *y, gint oldh, gint newh);
#define client_move(self, x, y) client_configure(self, x, y, self->area.width, self->area.height, TRUE, TRUE,FALSE)
#define client_move_resize(self, x, y, w, h) client_configure(self, x, y, w, h, TRUE, TRUE, FALSE)
#define client_reconfigure(self, force) client_configure(self, ((struct wm_client*)self)->area.x, \
	((struct wm_client*)self)->area.y, ((struct wm_client*)self)->area.width, \
	((struct wm_client*)self)->area.height, FALSE, TRUE, force)
void client_try_configure(struct wm_client *self, gint *x, gint *y, gint *w, gint *h, gint *logicalw, gint *logicalh,
	gboolean user);
void client_configure(struct wm_client *self, gint x, gint y, gint w, gint h, gboolean user, gboolean final,
	gboolean force_reply);
gboolean client_find_onscreen(struct wm_client *self, gint *x, gint *y, gint w, gint h, gboolean rude);
void client_move_onscreen(struct wm_client *self, gboolean rude);
void client_find_move_directional(struct wm_client *self, enum wm_direction dir, gint *x, gint *y);
void client_find_resize_directional(struct wm_client *self, enum wm_direction side, gboolean grow, gint *x, gint *y,
	gint *w, gint *h);
void client_fullscreen(struct wm_client *self, gboolean fs);
gboolean client_is_oldfullscreen(const struct wm_client const *self, const struct wm_rect *area);
void client_maximize(struct wm_client *self, gboolean max, gint dir);
void client_hilite(struct wm_client *self, gboolean hilite);
void client_close(struct wm_client *self);
void client_kill(struct wm_client *self);
void client_set_desktop(struct wm_client *self, guint target, gboolean donthide, gboolean dontraise);
gboolean client_show(struct wm_client *self);
gboolean client_hide(struct wm_client *self);
void client_showhide(struct wm_client *self);
gboolean client_validate(struct wm_client *self);
struct wm_client *client_focus_target(struct wm_client *self);
gboolean client_can_focus(struct wm_client *self);
gboolean client_focus(struct wm_client *self);
void client_activate(struct wm_client *self, gboolean desktop, gboolean here, gboolean raise, gboolean user);
void client_bring_helper_windows(struct wm_client *self);
void client_calc_layer(struct wm_client *self);
void client_update_transient_for(struct wm_client *self);
void client_update_protocols(struct wm_client *self);
void client_update_sync_request_counter(struct wm_client *self);
void client_update_colormap(struct wm_client *self, Colormap colormap);
void client_update_normal_hints(struct wm_client *self);
void client_update_wmhints(struct wm_client *self);
void client_update_title(struct wm_client *self);
void client_get_type_and_transientness(struct wm_client *self);
GSList *client_search_all_top_parents(struct wm_client *self);
GSList *client_search_all_top_parents_layer(struct wm_client *self);
struct wm_client *client_direct_parent(struct wm_client *self);
struct wm_client *client_search_top_direct_parent(struct wm_client *self);
gboolean client_is_direct_child(struct wm_client *parent, struct wm_client *child);
struct wm_client *client_search_transient(struct wm_client *self, struct wm_client *search);
void client_set_layer(struct wm_client *self, gint layer);
guint client_monitor(struct wm_client *self);
struct wm_client *client_under_pointer(void);
gboolean client_has_group_siblings(struct wm_client *self);
#endif
